﻿
using MediatR;
using Traceability.Commont.Domains.BatchManagementFiles;
using Traceability.Commont.DTOs.CommontFiles;
using Traceability.Commont.Infrastructures.Interfaces;

namespace U.Enterprise.Api.Applications.WhitestripWeighing
{
    public class WhiteStripWeighingViewHandler : IRequestHandler<WhiteStripWeighingViewCommond, Resqults>
    {

        private readonly IBateRepository<WhiteNotes> _WhiteNote;

        public WhiteStripWeighingViewHandler(IBateRepository<WhiteNotes> whiteNote)
        {
            _WhiteNote = whiteNote;
        }

        public async Task<Resqults> Handle(WhiteStripWeighingViewCommond request, CancellationToken cancellationToken)
        {
          
                var list = new Resqults() { Code = 0 };


                var query = _WhiteNote.GetAll().ToList();


            var num = request.pageindex - 1;
            query = query.Where(x => x.isyes == 0).OrderBy(x => x.WhiteNoteid).Skip(Convert.ToInt32(num)*Convert.ToInt32(request.pagesize)).Take(Convert.ToInt32(request.pagesize)).ToList();


            list.Date = query;


                return list;
          
           
        }
    }
}
